/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.test;


import com.comac.ins.common.core.utils.MapstructUtils;
import com.comac.ins.common.excel.utils.ExcelUtil;
import com.comac.ins.isfd.domain.bo.IsfdModelManagementOriginalPartBo;
import com.comac.ins.isfd.domain.vo.IsfdModelManagementOriginalPartVo;
import com.comac.ins.isfd.service.IIsfdModelManagementOriginalPartService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

@SpringBootTest
public class IsfdModelManagementOriginalPartTest {

    @Autowired
    private IIsfdModelManagementOriginalPartService isfdModelManagementOriginalPartService;

    @Test
    public void test1() {
        Path filePath = Paths.get("C:\\Users\\86166\\Desktop\\要素库项目\\模型管理\\原始装机清单.xlsx");

        try (InputStream inputStream = Files.newInputStream(filePath)) {
            List<IsfdModelManagementOriginalPartVo> targetVo = ExcelUtil.importExcel(inputStream, IsfdModelManagementOriginalPartVo.class);
            for (IsfdModelManagementOriginalPartVo vo : targetVo) {
                IsfdModelManagementOriginalPartBo bo = MapstructUtils.convert(vo, IsfdModelManagementOriginalPartBo.class);
                isfdModelManagementOriginalPartService.insertByBo(bo);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("hxloongs");
    }
}
